package com.glory.gloryquickui.adapter

import android.widget.CheckBox
import android.widget.CompoundButton
import android.widget.LinearLayout
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.glory.gloryquickui.R
import com.glory.gloryquickui.utils.FloatingWindowsUtils

class PopManyChooseAdapter(data: List<String?>?,
                           private val callback: FloatingWindowsUtils.PopManyChooseCallback) :
    BaseQuickAdapter<String?, BaseViewHolder>(
        R.layout.item_pop_many_choose_list,
        data as MutableList<String?>?
    ) {
    override fun convert(helper: BaseViewHolder, item: String?) {
        helper.setText(R.id.tvContent, item)
        val checkBox = helper.getView<CheckBox>(R.id.checkbox)
        helper.getView<LinearLayout>(R.id.llPopLayout).setOnClickListener{
            checkBox.isChecked = !checkBox.isChecked
            if (checkBox.isChecked){
                callback?.onChecked(item, helper.adapterPosition)
            }else{
                callback?.onUnChecked(item, helper.adapterPosition)
            }
        }
    }
}